package com.shadow.bus.main.setting;

import android.content.Context;

import com.shadow.bus.config.ItemFiled;
import com.shadow.bus.config.ItemType;
import com.shadow.bus.config.SpKey;
import com.shadow.bus.entity.LoginEntity;
import com.tepth.shadow.ui.recycler.MultipleItemEntity;
import com.zhangyu.shadow.core.util.app.AppUtils;
import com.zhangyu.shadow.core.util.storage.ShadowPreference;

import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangyu
 * @date 2018/7/3
 */

public class SettingDataConverter {
    public List<MultipleItemEntity> converter(Context context) {
        LoginEntity loginEntity = (LoginEntity) ShadowPreference.getCustomAppObj(SpKey.USER);
        List<MultipleItemEntity> list = new ArrayList<>();
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_TV)
                .setField(ItemFiled.FILED_NAME, "账号")
                .setField(ItemFiled.FILED_VALUE, ShadowPreference.getCustomAppProfile(SpKey.ACCOUNT))
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_TV)
                .setField(ItemFiled.FILED_NAME, "公司")
                .setField(ItemFiled.FILED_VALUE, loginEntity != null ? loginEntity.getOrgInfo().getName() : "")
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_TV)
                .setField(ItemFiled.FILED_NAME, "所属维修厂")
                .setField(ItemFiled.FILED_VALUE, loginEntity != null ? loginEntity.getDeptInfo().getName() : "")
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_TV)
                .setField(ItemFiled.FILED_NAME, "所属小组")
                .setField(ItemFiled.FILED_VALUE, loginEntity != null ? loginEntity.getGroupInfo().getName() : "")
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_CARD)
                .setField(ItemFiled.FILED_NAME, "打卡检测")
                .setField(ItemFiled.FILED_VALUE, ShadowPreference.getCustomAppProfile(SpKey.KEY_NFC_BIND_MAC))
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_CARD)
                .setField(ItemFiled.FILED_NAME, "检查更新")
                .setField(ItemFiled.FILED_VALUE, AppUtils.getVersion(context) + "")
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_CARD)
                .setField(ItemFiled.FILED_NAME, "环境")
                .setField(ItemFiled.FILED_VALUE, ShadowPreference.getAppFlag(SpKey.IS_DEBUG) ? "测试" : "正式")
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_RADIO_GROUP)
                .setField(ItemFiled.FILED_NAME, "打卡方式")
                .setField(ItemFiled.FILED_VALUE, ShadowPreference.getAppFlag(SpKey.KEY_CARD_WAY, true))
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_BUTTON)
                .setField(ItemFiled.FILED_NAME, "退出登录")
                .build());
        list.add(MultipleItemEntity.builder()
                .setItemType(ItemType.TYPE_SETTING_BUTTON)
                .setField(ItemFiled.FILED_NAME, "退出程序")
                .build());
        return list;
    }
}
